FROM crpi-4b5m1drruxllpt5o.cn-hangzhou.personal.cr.aliyuncs.com/mt-cloud/python:3.12-slim

ENV PIP_NO_CACHE_DIR=1

ARG AREA=china

COPY . /app

WORKDIR /app

RUN set -ex \
    && mkdir -p .pip  \
    && if [ 'china' = "$AREA" ] ; then \
      pip3 install -i https://mirrors.aliyun.com/pypi/simple --no-cache-dir -r requirements.txt; \
    else \
      pip3 install -r --no-cache-dir requirements.txt; \
    fi

# 设置环境变量（关键！确保 Django 输出直接打印到控制台）
ENV PYTHONUNBUFFERED=1
ENV DJANGO_SETTINGS_MODULE=mettler.settings

EXPOSE 8000

CMD ["python3", "/app/manage.py", "runserver", "0.0.0.0:8000"]